package com.ccsoft.thread.service;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.locks.LockSupport;

/**
 * 2021年12月17日 13:22:40 chanchaw
 * 控制线程执行的顺序
 */
@Slf4j
public class No11ExcuteOrder {

    public static void main(String[] args) {
        Thread t1 = new Thread(() -> {
            LockSupport.park();
            log.info("t1 -- 1");
        },"t1");


        Thread t2 = new Thread(() -> {
            LockSupport.unpark(t1);
            log.info("t2 -- 2");
        },"t2");

        t1.start();
        t2.start();
    }
}
